package com.shali.cloud.feign;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.shali.cloud.entity.User;

import feign.hystrix.FallbackFactory;

@Component
public class HystrixClientFallbackFactory implements FallbackFactory<UserFeignClient>{

	private static final Logger logger = LoggerFactory.getLogger(HystrixClientFallbackFactory.class);
	@Override
	public UserFeignClient create(Throwable cause) {
		HystrixClientFallbackFactory.logger.info("fallback reason:{}",cause.getMessage());
		return id -> {
			User u = new User();
			u.setId(-1L);
			return u;
		};
	}

}
